/* 
 * File:   players.h
 * Author: cow
 *
 * Created on May 8, 2011, 12:15 AM
 *
 * This set is the player abstract
 * and realization.  Therell be a single player
 * lib that is used to choose turn order and
 * keep track of fleets, resources, the foundry-state,
 * etc, etc.
 *
 */

#ifndef PLAYERS_H
#define	PLAYERS_H

//includes---------------------------------------
#include <map>
#include <vector>
#include <string>
#include <stdlib.h>
using namespace std;

//defines----------------------------------------
namespace Players{
static const int maxPlayers = 4;
enum turnOrder{
	fixed,
	random
};
}
//prototypes-------------------------------------
namespace Players{
class player;
class playerLib;
class shipyard;
class fleetmanager;
}
//dependent includes-----------------------------
#include "../PlayerData/unit.h"

//definitions------------------------------------
namespace Players{
//shipyard+++++++++
class shipyard{
public:
	//contructors-------
	shipyard();
	~shipyard();
	//access------------
	//manips------------
private:
};
//fleetmanager+++++
class fleetmanager{
public:
	//constructors------
	fleetmanager();
	~fleetmanager();
	//access------------
	int activeCells();
	int activeFleets();
	Units::unit* gCell(int x, int y);
	Units::unitgroup* gFleet(int id);
	Units::unitgroup* gFleet(int x, int y);
	//manips------------
	void endTurn();
	bool killFleet(int id);
	bool killFleet(int x, int y);
	int newFleet();
	void assignFleet(Units::unitgroup* fleet, Units::unit* u);
	Units::unit* newCell(Units::unit* cell);
	Units::unit* newCell(int fleetId, int x, int y);
private:
	map<int,Units::unitgroup*> fleetlist;
};
//player+++++++++++
class player{
public:
	//constructors------
	player(int id, string name);
	~player();
	//access------------
	string gName();
	fleetmanager* gFleetManager();
	bool played();
	//manips------------
	void setStart(int x, int y);
	void reset();
	void endTurn();
private:
	//identification----
	string playerName;
	int playerId;
	bool endedTurn;
	//libraries---------
	fleetmanager Fleets;
};
//playerLib++++++++
class playerLib{
public:	
	//constructors------
	playerLib();
	~playerLib();
	void newPlayer(string);
	//access------------
	player* gPlayer(int id);
	player* gCurentPlayer();
	int gCurrentPlayerId();
	//manips------------
	void setTurnOrderPolicy(turnOrder o);
	void resetAll();
	void endTurn();
private:
	int currentPlayer;
	turnOrder orderPolicy;
	vector<player> players;
};
}

#endif	/* PLAYERS_H */

